﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.ComponentModel;

namespace MessageWorkflow.Graph
{
    /// <summary>
    /// Defining the functionality required for  a graph
    /// </summary>
    public interface IGraph<T>
    {
        /// <summary>
        /// Adds the value to the known nodes 
        /// </summary>
        void Add(T value);

        /// <summary>
        /// Creates the set of predecessors for the value specified specified
        /// If a unknown predecessor is used, this will be registered nontheless
        /// </summary>
        /// <param name="value"></param>
        /// <param name="predecessors"></param>
        void AddPredecessors(T value, IEnumerable<T> predecessors);

        /// <summary>
        /// Removes a value and all its predecessors from the graph
        /// </summary>
        void Remove(T value);

        /// <summary>
        /// Removes the predecessors from the value specified, this requires the value to be known. If a unknown predecessor is used, this will be ignored
        /// </summary>
        void RemovePredecessors(T value, IEnumerable<T> predecessors);

        /// <summary>
        /// Get the set of nodes known in the graph
        /// </summary>
        IEnumerable<T> Nodes { get; }

        /// <summary>
        /// Get the set of direct predecessors for the value specified
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        IEnumerable<T> GetPredecessors(T value);

        /// <summary>
        /// Resets the whole graph removing all existing nodes and predecessors
        /// </summary>
        void Clear();
    }
}
